//
//  NameSP.cpp
//  Practice9
//
//  Created by 赵世杰 on 2020/7/5.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#include "NameSP.hpp"
#include <iostream>


using namespace std;

namespace SALES {


void setSales(Sales &s , const double ar[] , int n)
{
    double sum = 0;
    
    double max = ar[0];
    double min = ar[0];
    
    for (int i=0; i<n; i++)
    {
        double value = ar[i];
        
        s.sales[i] = value;
        
        sum += value;
        
        if(max<value)
        {
            max = value;
        }
        
        if(min>value)
        {
            min = value;
        }
        
    }
    
    s.average = sum/n;
    s.max = max;
    s.min = min;
    
    
}

void setSales(Sales &s)
{
    cout << "请输入四个季度的数据" << endl;
    
    double sum = 0;
    
    double max = 0 ;
    double min = 0 ;
    
    double data[4];
    
    for (int i=0; i<4; i++) {
        
        
        double value ;
        
        cout << "请输入" << i+1 << "季度的数据：" << endl;
        
        cin >> value;
        
        data[i] = value;
        
        
        if(i == 0)
        {
            max = value;
            min = value;
        }
        
        if(max < value)
        {
            max = value;
        }
        
        if(min > value)
        {
            min = value;
        }
        
        sum+=value;
        
    }
    
    
    s.average = sum/4;
    s.max = max;
    s.min = min;
    
}

void showSales(const Sales &s)
{
    for (int i=0; i<4; i++)
    {
        cout << i << "季度的营业额为：" << s.sales[i] << endl;
        
    }
    
    cout << "平均值为：" << s.average << " 最大值为：" << s.max << " 最小值为：" << s.min << endl;

}

}


